package ep.io;

import static org.junit.Assert.assertEquals;

import java.io.IOException;

import org.junit.Before;
import org.junit.Test;

import ep.model.Ant;
import ep.model.Board;

public class ReaderTest {

	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void testGetBoard() throws IOException {
		String args[] = {"ep/io/feed.pbm", "4x6", "1000000", "2"};

		Reader reader = new Reader(args);

		Board board = reader.getBoard();
		for (int i = 0; i < board.getHeight(); i++) {
			for (int j = 0; j < board.getWidth(); j++) {
				System.out.print(board.getPositionState(i, j)+"");
			}
			System.out.println();
		}

		assertEquals(new Ant(4,6), reader.getZ());
		assertEquals(1000000, reader.getIteractions());
		assertEquals(2, reader.getNumberOfProcessors());
	}

	@Test
	public void testP41() throws IOException {
		String args[] = {"ep/io/P4.pbm", "4x6", "1000000", "2"};
		Reader reader = new Reader(args);

		Board board = reader.getBoard();
		for (int i = 0; i < board.getHeight(); i++) {
			for (int j = 0; j < board.getWidth(); j++) {
				System.out.print(board.getPositionState(i, j));
			}
			System.out.println();
		}

		assertEquals(new Ant(4,6), reader.getZ());
		assertEquals(1000000, reader.getIteractions());
		assertEquals(2, reader.getNumberOfProcessors());
	}

	@Test
	public void testP4() throws IOException {
		String args[] = {"ep/io/betifaria.pbm", "4x6", "1000000", "2"};
		Reader reader = new Reader(args);

		Board board = reader.getBoard();
		for (int i = 0; i < board.getHeight(); i++) {
			for (int j = 0; j < board.getWidth(); j++) {
				System.out.print(board.getPositionState(i, j)+" ");
			}
			System.out.println();
		}

		assertEquals(new Ant(4,6), reader.getZ());
		assertEquals(1000000, reader.getIteractions());
		assertEquals(2, reader.getNumberOfProcessors());
	}
}
